import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, ActivatedRoute } from '@angular/router';
import { BrandApiService } from 'src/app/api/brand-api.service';
import { Observable } from 'rxjs';
import { Brand } from 'src/app/model/brand';

@Injectable()
export class BrandDetailResolverService implements Resolve<Brand>{

  constructor(
    // private route: ActivatedRoute,
    private brandApi: BrandApiService,
  ) { }
  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Brand> | Observable<never> {
      return this.brandApi.fetchItem(route.queryParams.id);
  }
}
